package com.dinggao.crossgo.module.roadbook.activity;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.dinggao.crossgo.R;
import com.dinggao.crossgo.core.base.BaseActivity;
import com.dinggao.crossgo.core.constant.CommonConstant;
import com.dinggao.crossgo.core.manage.ApiManager;
import com.dinggao.crossgo.core.observer.EventIntet;
import com.dinggao.crossgo.core.observer.EventMsg;
import com.dinggao.crossgo.core.observer.PrivateObserver;
import com.dinggao.crossgo.core.ui.FullyGridLayoutManager;
import com.dinggao.crossgo.core.ui.ScrollEditText;
import com.dinggao.crossgo.core.util.GifSizeFilter;
import com.dinggao.crossgo.core.util.Glide4Engine;
import com.dinggao.crossgo.core.util.LogUtils;
import com.dinggao.crossgo.core.util.NetUtils;
import com.dinggao.crossgo.core.util.SharedPreferencesUtil;
import com.dinggao.crossgo.core.util.ToastUtil;
import com.dinggao.crossgo.module.roadbook.adapter.ReleaseAdapter;
import com.dinggao.crossgo.module.roadbook.data.RoadDetailsBean;
import com.dinggao.crossgo.module.roadbook.data.UriBean;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Progress;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.wang.avi.AVLoadingIndicatorView;
import com.zhihu.matisse.Matisse;
import com.zhihu.matisse.MimeType;
import com.zhihu.matisse.filter.Filter;
import com.zhihu.matisse.internal.entity.CaptureStrategy;

import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import top.zibin.luban.CompressionPredicate;
import top.zibin.luban.Luban;
import top.zibin.luban.OnCompressListener;


public class RoadBookPublishReleaseActivity extends BaseActivity implements PrivateObserver {


    @BindView(R.id.release_jd)
    Button releaseJd;
    @BindView(R.id.release_ydq)
    Button releaseYdq;
    @BindView(R.id.release_tcq)
    Button releaseTcq;
    @BindView(R.id.release_jyz)
    Button releaseJyz;
    @BindView(R.id.release_xsj)
    Button releaseXsj;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerView;
    @BindView(R.id.release_finish)
    Button releaseFinish;

    public static final String TAG = "RELEASE";
    @BindView(R.id.release_edit)
    ScrollEditText edit_Release;
    @BindView(R.id.loction_gps)
    TextView loctionGps;
    @BindView(R.id.pbProgress)
    AVLoadingIndicatorView pbProgress;
    @BindView(R.id.scrollview)
    ScrollView scrollview;
    @BindView(R.id.iv_top_bar_left)
    ImageView ivTopBarLeft;
    @BindView(R.id.tv_top_bar_title)
    TextView tvTopBarTitle;
    @BindView(R.id.iv_top_bar_right)
    ImageView ivTopBarRight;
    @BindView(R.id.location_layout)
    LinearLayout locationLayout;
    @BindView(R.id.line_location)
    View lineLocation;
    @BindView(R.id.choose_text)
    TextView chooseText;

    private ReleaseAdapter adapter;
    private static final int REQUEST_CODE_CHOOSE = 23, REQ_THUMB = 22;
    private int maxphoto = 9;

    private List<UriBean> uriData;
    private UriBean uriBean;
    //标签按钮选中状态判断标识
    private Boolean button_jd = false, button_ydq = false, button_tcq = false, button_jyz = false, button_xsj = false;
    private List<String> tabList;
    //上传文件
    private List<File> filesData;

    private double Latitude, Longitude;
    private String location;
    private String tab = "";
    private int roadBookId;
    private File filesDir;
    private int jourId;
    private boolean blackDetail = false;
    private List<Integer> idList;
    private List<Integer> deleteList;

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_release;
    }


    @Override
    protected void onInitialization(Bundle bundle) {

        EventIntet.getDefault().register(this);
        uriData = new ArrayList<>();
        filesData = new ArrayList<File>();
        tabList = new ArrayList<>();
        idList = new ArrayList<>();
        deleteList = new ArrayList<>();
        tvTopBarTitle.setText("编辑路书");
        intentData();

        adapter = new ReleaseAdapter(R.layout.item_uri, uriData);
        recyclerView.setLayoutManager(new FullyGridLayoutManager(this, 3));
        recyclerView.setAdapter(adapter);

        if (idList.size() != 9) {
            Resources r = getApplicationContext().getResources();
            final Uri uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
                    + r.getResourcePackageName(R.drawable.road_publish_photo_add) + "/"
                    + r.getResourceTypeName(R.drawable.road_publish_photo_add) + "/"
                    + r.getResourceEntryName(R.drawable.road_publish_photo_add));

            uriBean = new UriBean();
            uriBean.setTag(false);
            uriBean.setUri(uri);
            uriData.add(uriBean);
        }

        dealEditListener();
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                LogUtils.e("sadd", uriData.size() + "");
                if (blackDetail) {

                    if (!uriData.get(uriData.size() - 1).getTag()) {
                        if (position == (uriData.size() - 1)) {
                            maxphoto = 9 - uriData.size() + 1;
                            choosePhoto(maxphoto);
                            adapter.notifyDataSetChanged();
                        }
                    } else {
                        ToastUtil.showLong(RoadBookPublishReleaseActivity.this, "最多只能上传九张图片");
                    }

                } else {
                    if (!uriData.get(uriData.size() - 1).getTag()) {
                        maxphoto = 9 - uriData.size() + 1;
                        choosePhoto(maxphoto);
                        adapter.notifyDataSetChanged();
                    }
                }


            }
        });


    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventIntet.getDefault().unregister(this);
    }

    private void dealEditListener() {

        //输入字数监听
        edit_Release.addTextChangedListener(new TextWatcher() {

            private CharSequence temp;
            private int editStart;
            private int editEnd;

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                temp = s;

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {

                editStart = edit_Release.getSelectionStart();
                editEnd = edit_Release.getSelectionEnd();
                //  tv_show.setText("您输入了" + temp.length() + "个字符");
                if (temp.length() > 1000) {
                    s.delete(editStart - 1, editEnd);
                    int tempSelection = editStart;
                    edit_Release.setText(s);
                    edit_Release.setSelection(tempSelection);
                    Toast.makeText(RoadBookPublishReleaseActivity.this, "请不要超过1000字哦！！", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }

    private int tagnum = 0;

    private void intentData() {

        // TODO: 2018/8/13  数据库读取保存内容


        DecimalFormat df = new DecimalFormat("######0.00");
        Intent intent = getIntent();
        if (getIntent().getStringExtra("RoadBookPublishDetailsActivity") != null) {
            final RoadDetailsBean roadDetailsBean = (RoadDetailsBean) intent.getSerializableExtra("RoadDetailsBean");
            blackDetail = true;
            if (roadDetailsBean.getData() != null) {
                jourId = roadDetailsBean.getData().getId();
                edit_Release.setText(roadDetailsBean.getData().getContent());
                roadBookId = roadDetailsBean.getData().getRoadBookId();
                Latitude = roadDetailsBean.getData().getLatitude();
                Longitude = roadDetailsBean.getData().getLongitude();
                location = roadDetailsBean.getData().getLocation();
                tab = roadDetailsBean.getData().getTab();
                if (tab.contains("景点")) {
                    button_jd = true;
                    releaseJd.setSelected(true);
                }
                if (tab.contains("营地区")) {
                    button_ydq = true;
                    releaseYdq.setSelected(true);
                }
                if (tab.contains("停车区")) {
                    button_tcq = true;
                    releaseTcq.setSelected(true);
                }
                if (tab.contains("加油站")) {
                    button_jyz = true;
                    releaseJyz.setSelected(true);
                }
                if (tab.contains("洗手间")) {
                    button_xsj = true;
                    releaseXsj.setSelected(true);
                }
                loctionGps.setText("GPS  " + df.format(Latitude) + "," + df.format(Longitude));
                for (tagnum = 0; tagnum < roadDetailsBean.getData().getImgs().size(); tagnum++) {
                    idList.add(roadDetailsBean.getData().getImgs().get(tagnum).getId());
                    uriData.add(new UriBean(true, Uri.parse(ApiManager.IMAG_URL +
                            roadDetailsBean.getData().getImgs().get(tagnum).getImg())));

                }
            }
            LogUtils.e(TAG, idList.size() + "");

        } else {

            roadBookId = intent.getExtras().getInt("roadBookId");
            Latitude = (double) intent.getExtras().get("Latitude");
            Longitude = (double) intent.getExtras().get("Longitude");
            location = intent.getStringExtra("location");
            loctionGps.setText("GPS  " + df.format(Latitude) + "," + df.format(Longitude));

            switch (Integer.valueOf(intent.getStringExtra("number"))) {
                case 0:

                    break;
                case 1:

                    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    filesDir = new File(Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                            .getAbsolutePath() + File.separator + "camerademo" + System.currentTimeMillis());
                    filesDir.getParentFile().mkdirs();

                    //改变Uri  com.xykj.customview.fileprovider注意和xml中的一致
                    Uri uri = FileProvider.getUriForFile(this, "com.dinggao.crossgo.fileprovider", filesDir);
                    LogUtils.e("uri", uri);
                    //添加权限
                    takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                    startActivityForResult(takePictureIntent, REQ_THUMB);
                    //将刚拍照的相片在相册中显示


                    break;
                case 2:

                    Matisse.from(RoadBookPublishReleaseActivity.this)
                            .choose(MimeType.ofImage())//ofAll()
                            .theme(R.style.Matisse_Custom)//主题，夜间模式R.style.Matisse_Dracula
                            .countable(true)//是否显示选中数字
                            .maxSelectable(9)//最大选择数
                            .addFilter(new GifSizeFilter(120, 120, 5 * Filter.K * Filter.K))//筛选条件
                            .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))//图片大小
                            .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)//屏幕方向
                            .thumbnailScale(0.85f)//缩放比例
                            .imageEngine(new Glide4Engine())//图片加载方式
                            .forResult(REQUEST_CODE_CHOOSE);//请求码


                    break;
                default:

                    break;
            }

        }


    }


    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            View v = getCurrentFocus();
            //当isShouldHideInput(v, ev)为true时，表示的是点击输入框区域，则需要显示键盘，同时显示光标，反之，需要隐藏键盘、光标
            if (isShouldHideInput(v, ev)) {

                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                    //处理Editext的光标隐藏、显示逻辑
                    edit_Release.clearFocus();
                }
            }
            return super.dispatchTouchEvent(ev);
        }
        // 必不可少，否则所有的组件都不会有TouchEvent了
        if (getWindow().superDispatchTouchEvent(ev)) {
            return true;
        }
        return onTouchEvent(ev);
    }

    public boolean isShouldHideInput(View v, MotionEvent event) {
        if (v != null && (v instanceof EditText)) {
            int[] leftTop = {0, 0};
            //获取输入框当前的location位置
            v.getLocationInWindow(leftTop);
            int left = leftTop[0];
            int top = leftTop[1];
            int bottom = top + v.getHeight();
            int right = left + v.getWidth();
            if (event.getX() > left && event.getX() < right
                    && event.getY() > top && event.getY() < bottom) {
                // 点击的是输入框区域，保留点击EditText的事件
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    @OnClick({R.id.iv_top_bar_left, R.id.release_jd, R.id.release_ydq, R.id.release_tcq, R.id.release_jyz, R.id.release_xsj, R.id.release_finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_top_bar_left:
                EventIntet.getDefault().post(new EventMsg("RoadBookPublishReleaseActivity-upade", 9901, String.valueOf(getClass().getName())));
                finish();
                break;
            case R.id.release_jd:

                if (!button_jd) {
                    button_jd = true;
                    releaseJd.setSelected(true);
                } else {
                    button_jd = false;
                    releaseJd.setSelected(false);
                }
                break;
            case R.id.release_ydq:
                if (!button_ydq) {
                    button_ydq = true;
                    releaseYdq.setSelected(true);
                } else {
                    button_ydq = false;
                    releaseYdq.setSelected(false);
                }
                break;
            case R.id.release_tcq:
                if (!button_tcq) {
                    button_tcq = true;
                    releaseTcq.setSelected(true);
                } else {
                    button_tcq = false;
                    releaseTcq.setSelected(false);
                }
                break;
            case R.id.release_jyz:
                if (!button_jyz) {
                    button_jyz = true;
                    releaseJyz.setSelected(true);
                } else {
                    button_jyz = false;
                    releaseJyz.setSelected(false);
                }
                break;
            case R.id.release_xsj:
                if (!button_xsj) {
                    button_xsj = true;
                    releaseXsj.setSelected(true);
                } else {
                    button_xsj = false;
                    releaseXsj.setSelected(false);
                }
                break;
            case R.id.release_finish:

                if (NetUtils.isNetworkAvailable(this)) {

                    if (filesData.size() == 0 && deleteList.size() == 0 && idList.size() == 0 && edit_Release.getText().toString().trim().length() == 0
                            || deleteList.size() == 9 && filesData.size() == 0 && edit_Release.getText().toString().trim().length() == 0) {
                        Toast.makeText(RoadBookPublishReleaseActivity.this, "    上传的内容不能为空哦    ", Toast.LENGTH_LONG).show();
                        releaseFinish.setClickable(true);
                    } else {
                        tab = dealTab();
                        releaseNet(tab, edit_Release.getText().toString().trim());
                        releaseFinish.setClickable(false);
                    }

                } else {
                    ToastUtil.showLong(this, "当前无网络连接");
                }

                break;
        }


    }


    private String dealTab() {
        if (button_jd) {
            tabList.add("景点");
        }
        if (button_ydq) {
            tabList.add("营地区");
        }
        if (button_tcq) {
            tabList.add("停车区");
        }
        if (button_jyz) {
            tabList.add("加油站");
        }
        if (button_xsj) {
            tabList.add("洗手间");
        }
        String tab = "";
        if (tabList != null && tabList.size() > 0) {
            for (int i = 0; i < tabList.size(); i++) {
                if (i == tabList.size() - 1) {
                    tab = tab + tabList.get(i);
                } else {
                    tab = tab + tabList.get(i) + ",";
                }

            }
        }
        return tab;
    }

    //发布网络请求
    private void releaseNet(String tab, String content) {

        HttpParams params = new HttpParams();
        params.put("roadBookId", roadBookId);
        if (blackDetail) {
            params.put("jourId", jourId);
        }
        if (deleteList != null && deleteList.size() > 0) {

            String deleteStr = "";
            if (deleteList.size() == 1) {
                deleteStr = deleteList.get(0) + "";
            } else {
                for (int i = 0; i < deleteList.size(); i++) {
                    if (i == deleteList.size() - 1) {
                        deleteStr = deleteStr + deleteList.get(i);
                    } else {
                        deleteStr = deleteStr + deleteList.get(i) + ",";
                    }
                    LogUtils.e("删除的id是", "删除的id是:" + deleteList.get(i));
                }
            }

            params.put("attachIds", deleteStr);//deleteid
        }
        params.put("location", location);
        params.put("lng", Longitude);
        params.put("lat", Latitude);
        params.put("tab", tab);
        params.put("journalContent", content);
        String url = "";
        if (blackDetail) {
            url = ApiManager.ROADBOOKJOURNAL_UPDATE;
        } else {
            url = ApiManager.ROADBOOKJOURNAL_ADD;
        }
        OkGo.<String>post(url)
                .headers("accessToken", SharedPreferencesUtil.getSharedPreferencesString(RoadBookPublishReleaseActivity.this, CommonConstant.USERINFO_SHREDPREFERENCE,
                        CommonConstant.USRERINFO_SHRAREDPREFERCE_ACCESS_TOKEN))
                .tag(this)
                .params(params)
                .addFileParams("files", filesData)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        releaseFinish.setClickable(true);
                        blackDetail = false;
                        LogUtils.e(TAG, "onSuccess: " + response.body());
                        EventIntet.getDefault().post(new EventMsg("RoadBookPublishReleaseActivity-upade", 9902, String.valueOf(getClass().getName())));
                        finish();
                    }

                    @Override
                    public void uploadProgress(Progress progress) {
                        super.uploadProgress(progress);
                        //该回调在主线程,可以直接更新ui
                    }

                    @Override
                    public void onError(Response<String> response) {
                        ToastUtil.showLong(RoadBookPublishReleaseActivity.this, "上传失败");
                        LogUtils.e(TAG, "onError: " + response.getException().toString());
                        releaseFinish.setClickable(true);
                    }

                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        //开始加载进度条
                        pbProgress.setVisibility(View.VISIBLE);

                        pbProgress.show();
                        LogUtils.e(TAG, "ONSTART");
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();

                        pbProgress.setVisibility(View.GONE);
                        //结束进度条
                        pbProgress.hide();
                        releaseFinish.setClickable(true);
                    }
                });
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {

            if (!uriData.get(uriData.size() - 1).getTag()) {
                uriData.remove(uriData.size() - 1);
            }
            switch (requestCode) {
                case REQ_THUMB:
                    Uri photo = FileProvider.getUriForFile(this, "com.dinggao.crossgo.fileprovider", filesDir);
                    UriBean photoUri = new UriBean();
                    photoUri.setTag(true);
                    photoUri.setUri(photo);
                    uriData.add(photoUri);

                    Luban.with(this)
                            .load(filesDir)
                            .ignoreBy(100)
                            .setTargetDir("")
                            .filter(new CompressionPredicate() {
                                @Override
                                public boolean apply(String path) {
                                    return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
                                }
                            })
                            .setCompressListener(new OnCompressListener() {
                                @Override
                                public void onStart() {

                                }

                                @Override
                                public void onSuccess(File file) {
                                    LogUtils.e("luban", "压缩成功");
                                    filesData.add(file);
                                }

                                @Override
                                public void onError(Throwable e) {
                                    LogUtils.e("luban", e.getMessage());
                                }
                            }).launch();

                    break;
                case REQUEST_CODE_CHOOSE:
                    for (int i = 0; i < Matisse.obtainPathResult(data).size(); i++) {
                        Luban.with(this)
                                .load(new File(Matisse.obtainPathResult(data).get(i)))
                                .ignoreBy(100)
                                .setTargetDir("")
                                .filter(new CompressionPredicate() {//开启压缩条件
                                    @Override
                                    public boolean apply(String path) {
                                        return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
                                    }
                                })
                                .setCompressListener(new OnCompressListener() {
                                    @Override
                                    public void onStart() {

                                    }

                                    @Override
                                    public void onSuccess(File file) {

                                        filesData.add(file);
                                    }

                                    @Override
                                    public void onError(Throwable e) {
                                        LogUtils.e("luban", e.getMessage());
                                    }
                                }).launch();
                    }

                    for (int i = 0; i < Matisse.obtainResult(data).size(); i++) {
                        UriBean bean = new UriBean();
                        bean.setTag(true);
                        bean.setUri(Matisse.obtainResult(data).get(i));
                        uriData.add(bean);

                    }
                    break;
                default:
                    break;
            }


            if (uriData.size() == 0 || uriData.get(uriData.size() - 1).getTag() && uriData.size() < 9) {
                Resources r = getApplicationContext().getResources();
                Uri uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
                        + r.getResourcePackageName(R.drawable.road_publish_photo_add) + "/"
                        + r.getResourceTypeName(R.drawable.road_publish_photo_add) + "/"
                        + r.getResourceEntryName(R.drawable.road_publish_photo_add));

                uriBean = new UriBean();
                uriBean.setTag(false);
                uriBean.setUri(uri);
                uriData.add(uriBean);

            }

            adapter.notifyDataSetChanged();

        }

    }


    private void choosePhoto(final int maxPhoto) {

        Matisse.from(RoadBookPublishReleaseActivity.this)
                .choose(MimeType.ofImage())//ofAll()
                .theme(R.style.Matisse_Custom)//主题，夜间模式R.style.Matisse_Dracula
                .countable(true)//是否显示选中数字
                .capture(true)//是否提供拍照功能
                .captureStrategy(new CaptureStrategy(true, "com.dinggao.crossgo.fileprovider"))//存储地址
                .maxSelectable(maxPhoto)//最大选择数
                .addFilter(new GifSizeFilter(120, 120, 5 * Filter.K * Filter.K))//筛选条件
                .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))//图片大小
                .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)//屏幕方向
                .thumbnailScale(0.85f)//缩放比例
                .imageEngine(new Glide4Engine())//图片加载方式
                .forResult(REQUEST_CODE_CHOOSE);//请求码

    }


    //根据adapter删除的position来删除file集合指定的文件
    @Override
    public void update(Object obj) {
        if (!(obj instanceof EventMsg)) {
            return;
        }
        EventMsg eventMsg = (EventMsg) obj;
        if (eventMsg.getMsg().equals("ReleaseAdapter--delete")) {

            if (blackDetail) {
                LogUtils.e("number", eventMsg.getCode() + "");
                if (idList != null && idList.size() > 0) {
                    LogUtils.e("number", idList.get(eventMsg.getCode()) + "");
                    deleteList.add(idList.get(eventMsg.getCode()));
                    idList.remove(eventMsg.getCode());
                }

            }

            if (filesData != null && filesData.size() > 0) {
                filesData.remove(eventMsg.getCode());
            }


        }
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }


}
